package st.business.tepth.business.taskallocation.returnfactory;

import java.util.ArrayList;
import java.util.List;

import st.business.tepth.business.bean.CommonBean;
import st.business.tepth.business.bean.ReturnFactoryBean;
import st.business.tepth.config.ItemFields;
import st.shadow.library.ui.recycler.MultipleItemEntity;

/**
 * @author zhangyu
 * @date 2019/9/3
 */
public class ReturnFactoryDataConvert {
    public static List<MultipleItemEntity>
    convertToClassification(ReturnFactoryBean bean) {
        List<MultipleItemEntity> list = new ArrayList<>();
        if (bean != null) {
            List<ReturnFactoryBean.Classification> unSolveTaskList = bean.getUnSolveTaskList();
            if (unSolveTaskList != null) {
                for (int i = 0, size = unSolveTaskList.size(); i < size; i++) {
                    ReturnFactoryBean.Classification classification
                            = unSolveTaskList.get(i);
                    List<CommonBean> unSolvePhenomenonList =
                            classification.getRepairPhenomenonList();
                    list.add(MultipleItemEntity.builder().setField("name",
                            classification.getSeriesName())
                            .setField("checked", i == 0)
                            .setField("count", unSolvePhenomenonList == null ? 0 :
                                    unSolvePhenomenonList.size())
                            .setField(ItemFields.ITEM_OBJ,classification)
                            .setField("id", classification.getId())
                            .build());
                }
            }
        }
        return list;
    }
}
